<?php
/**
 * 课程管理首页
 */
include "../util/DBUtil.php";

$sql = "select * from tb_course";
$db = new DBUtil();
$action = $_GET["action"];
$params = array();
if ($action =="key"){
    $key = $_POST['key'];//获取关键字
    $sql = "select * from tb_course where course like ?";
    $params = array("%".$key."%");
}
$result = $db->query($sql,$params);//获取所有班级
?>
<link rel="stylesheet" href="../css/bootstrap.min.css">
<table class="table table-striped">
    <tr>
        <th>ID</th>
        <th>课程</th>
        <th>编辑</th>
    </tr>
    <?php
    foreach ($result as $item){
        ?>
        <tr>
            <td><?php echo $item['id']?></td>
            <td><?php echo $item['course']?></td>
            <td>
                <a href="../view/edit_course.php?id=<?php echo $item['id']?>&flag=0" target="info">
                    <button class="btn btn-primary">修改</button>
                </a>
                <a href="../view/edit_course.php?id=<?php echo $item['id']?>&flag=1" target="info">
                    <button onclick="alert('是否删除？')" class="btn btn-danger">删除</button>
                </a>
            </td>
        </tr>
        <?
    }
    ?>
</table>